from pages.base_page import BasePage


class MinePage(BasePage):
    first_trend_content = '//*[@resource-id="cool.dingstock.mobile:id/circle_item_dynamic_content_txt"]'
    first_trend_topic = '//*[@resource-id="cool.dingstock.mobile:id/topic_title_tv"]'
    menu_xpath = '//*[@resource-id="cool.dingstock.mobile:id/mine_top_left_menu"]'
    my_collect = '//*[@text="我的收藏"]'
    first_collect_trend_content = '//*[@resource-id="cool.dingstock.mobile:id/circle_item_dynamic_content_txt"]'
    home_xpath = '//*[@resource-id="cool.dingstock.mobile:id/home_activity_bottom_tab_view"]/android.widget.LinearLayout[1]/android.widget.LinearLayout[1]/android.view.ViewGroup[1]/android.widget.FrameLayout[1]'
    first_trend_delete = '//*[@resource-id="cool.dingstock.mobile:id/post_header_overlay"]'
    first_trend_delete1 = '//*[@resource-id="cool.dingstock.mobile:id/rv_post_action"]'
    first_trend_delete_confirm = '//*[@resource-id="cool.dingstock.mobile:id/confirm_tv"]'
    my_collect_sale = '//*[@resource-id="cool.dingstock.mobile:id/title_container"]/android.widget.FrameLayout[2]/android.widget.LinearLayout[1]'
    first_sale_content = '//*[@resource-id="cool.dingstock.mobile:id/trading_tv"]'
    first_sale_menu = '//*[@resource-id="cool.dingstock.mobile:id/rv"]/android.view.ViewGroup[1]/android.widget.LinearLayout[1]/android.widget.FrameLayout[1]/android.widget.LinearLayout[1]/android.view.ViewGroup[1]/android.widget.LinearLayout[1]/androidx.appcompat.widget.LinearLayoutCompat[1]/android.widget.LinearLayout[1]/android.widget.FrameLayout[1]/android.widget.ImageView[1]'
    first_sale_delete = '//*[@resource-id="cool.dingstock.mobile:id/rv_post_action"]'
    sale_delete_confirm = '//*[@resource-id="cool.dingstock.mobile:id/confirm_tv"]'
    customer_button = '//*[@resource-id="cool.dingstock.mobile:id/drawer_mine_iv_customer"]'
    customer_center_title = '//*[@resource-id="cool.dingstock.mobile:id/webview_tv_title"]'
    edit_information = '//*[@text="编辑资料"]'
    member_activation_code = '//*[@text="会员激活码"]'
    dark_mode = '//*[@text="深色模式"]'
    privacy_policy = '//*[@text="隐私政策"]'
    application_permission = '//*[@text="应用权限"]'
    personal_information = '//*[@text="个人信息收集清单"]'
    tripartite_information = '//*[@text="第三方信息共享清单"]'
    title = '//*[@resource-id="cool.dingstock.mobile:id/common_titlebar_title_tv"]'
    back_button = '//*[@resource-id="cool.dingstock.mobile:id/common_titlebar_left_icon"]'
    sign_input = '//*[@resource-id="cool.dingstock.mobile:id/edt_signature"]'
    save_edit = '//*[@text="保存"]'
    user_sign = '//*[@resource-id="cool.dingstock.mobile:id/tv_user_desc"]'
    activation_window_code = '//*[@resource-id="cool.dingstock.mobile:id/title"]'
    activation_code_input = '//*[@resource-id="cool.dingstock.mobile:id/edit"]'
    activation_window_confirm = '//*[@resource-id="cool.dingstock.mobile:id/confirm_tv"]'
    privacy_policy_title = '//*[@resource-id="cool.dingstock.mobile:id/webview_tv_title"]'
    privacy_policy_back = '//*[@resource-id="cool.dingstock.mobile:id/webview_iv_back"]'




    def get_newest_trend_content(self):
        """获取我的最新动态文本"""
        return self.get_xpath_text(self.first_trend_content)

    def get_newest_trend_topic(self):
        """获取我的最新动态话题"""
        return self.get_xpath_text(self.first_trend_topic)

    def click_menu(self):
        """点击菜单"""
        self.click_xpath(self.menu_xpath)

    def click_my_collect(self):
        """点击我的收藏"""
        self.click_xpath(self.my_collect)

    def get_first_collect_content(self):
        """获取第一个收藏动态的内容"""
        return self.get_xpath_text(self.first_collect_trend_content)

    def switch_home(self):
        """切换到首页"""
        self.click_xpath(self.home_xpath)

    def delete_my_first_trend(self):
        """删除我的第一个动态"""
        self.click_xpath(self.first_trend_delete)
        self.click_xpath(self.first_trend_delete1)
        self.click_xpath(self.first_trend_delete_confirm)

    def click_my_collect_sale(self):
        """查看我收藏的交易"""
        self.click_xpath(self.my_collect_sale)

    def get_my_collect_sale_content(self):
        """获取我的收藏交易的内容"""
        return self.get_xpath_text(self.first_sale_content)

    def delete_first_sale(self):
        """删除我发布的最新一条交易"""
        self.click_xpath(self.first_sale_menu)
        self.click_xpath(self.first_sale_delete)
        self.click_xpath(self.sale_delete_confirm)
        
    def into_customer_center(self):
        """进入客服中心"""
        self.click_xpath(self.menu_xpath)
        self.click_xpath(self.customer_button)
        
    def customer_title(self):
        """客服中心顶部title"""
        return self.get_xpath_text(self.customer_center_title)

    def into_edit_information(self, text):
        """编辑资料,修改签名"""
        self.click_xpath(self.edit_information)
        title = self.get_xpath_text(self.title)
        self.set_xpath_text(self.sign_input, text)
        self.click_xpath(self.save_edit)
        return title

    def get_user_sign(self):
        """个人中心主页获取用户签名"""
        return self.get_xpath_text(self.user_sign)

    def try_member_activation(self, text):
        """会员激活码输入错误激活码，点击确定"""
        self.click_xpath(self.member_activation_code)
        self.set_xpath_text(self.activation_code_input, text)
        pop_up = self.get_xpath_text(self.activation_window_code)
        self.click_xpath(self.activation_window_confirm)
        return pop_up

    def into_dark_mode(self):
        """进入深色模式"""
        self.click_menu()
        self.click_xpath(self.dark_mode)
        title = self.get_xpath_text(self.title)
        self.click_xpath(self.back_button)
        return title

    def into_privacy_policy(self):
        """进入隐私政策"""
        self.click_menu()
        self.click_xpath(self.privacy_policy)
        title = self.get_xpath_text(self.privacy_policy_title)
        self.click_xpath(self.privacy_policy_back)
        return title

    def into_application_permission(self):
        """进入应用权限"""
        self.click_menu()
        self.click_xpath(self.application_permission)
        title = self.get_xpath_text(self.privacy_policy_title)
        self.click_xpath(self.privacy_policy_back)
        return title

    def into_tripartite_information(self):
        """进入三方信息收集清单"""
        self.click_menu()
        self.click_xpath(self.tripartite_information)
        title = self.get_xpath_text(self.privacy_policy_title)
        self.click_xpath(self.privacy_policy_back)
        return title

    def into_personal_information(self):
        """进入个人信息收集清单"""
        self.click_menu()
        self.click_xpath(self.personal_information)
        title = self.get_xpath_text(self.privacy_policy_title)
        self.click_xpath(self.privacy_policy_back)
        return title